package com.acxy.ants.resful;

import com.acxy.ants.common.enums.RequestMethod;
import com.alibaba.fastjson.JSON;

import java.lang.reflect.Method;

/**
 * @author MrShun
 * @version 1.0
 * @Date 2017-04-26
 */
public class RequestMapping {

    //请求多配置URLS
    private final String[] urls;

    //匹配到的目标配置URL
    private String currentUrl;

    //请求类型
    private RequestMethod requstType;

    //URL映射的已结New了的Class对象
    private final Object object;

    //URL映射的Class对象方法
    private final Method method;

    //URL所属模块
    private String moduleName;

    public RequestMapping(String[] urls, String currentUrl, RequestMethod requstType, Object object, Method method, String moduleName) {
        this.urls = urls;
        this.currentUrl = currentUrl;
        this.requstType = requstType;
        this.object = object;
        this.method = method;
        this.moduleName = moduleName;
    }

    public String[] getUrls() {
        return urls;
    }

    public String getCurrentUrl() {
        return currentUrl;
    }

    public void setCurrentUrl(String currentUrl) {
        this.currentUrl = currentUrl;
    }

    public RequestMethod getRequstType() {
        return requstType;
    }

    public Object getObject() {
        return object;
    }

    public Method getMethod() {
        return method;
    }

    public String getModuleName() {
        return moduleName;
    }

    public void setModuleName(String moduleName) {
        this.moduleName = moduleName;
    }

    public String toString() {
        StringBuilder builder = new StringBuilder("{");
        builder.append("urls=").append(JSON.toJSONString(urls));
        builder.append("], type=[").append(requstType);
        builder.append("], method=[").append(method);
        if(moduleName != null)
            builder.append("], module=[").append(moduleName);
        builder.append("]}");
        return builder.toString();
    }
}
